"""
   -*- coding: utf-8 -*-
   @Time    : 2021/4/23 14:06
   @Author  : 狠欢
   @File    : lianxi.py
   @Software: PyCharm
"""
# 用户密码复杂度验证(封装成函数)
# 长度超过8位（必须)+1分
# 包括大、小写字母.数字.其它符号,以上四种至少三种+1分
# 不能有长度超过或等于3的子串重复+1分
# 密码的评分等级，默认2分，以上条件满足一条加1分
# 返回密码的评分等级，及要改进的点:
# 如return 3,['长度小于8'，'密码没有由3种以上字符组成'"]
import string
grade = 2


passwd = input("请输入你的密码：")



def passwd_judge1():
    if len(passwd)>8:
        global grade
        grade = grade+1
    else:
        print("您的密码长度小于8位")

def passwd_judge2():
        global grade
        m1 = m2 = m3 = m4 = 0
        a1 = string.ascii_uppercase
        for i in passwd:
            if i in a1:
                m1=1
                break
        a2 = string.ascii_lowercase
        for i in passwd:
            if i in a2:
                m2 = 1
                break
        a3 = string.digits
        for i in passwd:
            if i in a3:
                m3 = 1
                break
        for i in passwd:
            if i not in string.ascii_uppercase+string.digits:
                m4=1
                break
        m = m1+m2+m3+m4
        if m>=3:
            grade = grade+1
        else:
            print("密码没有由3种以上字符组成")


def passwd_judge3():
    global grade
    for i in range(len(passwd)):
        if passwd.count(passwd[i:i+3])>=2:
            print("您的字符串重复超过3")
            break
    else:
        grade = grade+1


passwd_judge1()
passwd_judge2()
passwd_judge3()
print(grade)





















